package com.cqndt.disaster.device.controller;

import java.util.Map;
import java.util.List;
import com.cqndt.disaster.device.util.Result;
import com.cqndt.disaster.device.vo.TabUserVo;
import com.cqndt.disaster.device.util.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cqndt.disaster.device.service.DataStatisticsService;

/**
 * @author lgb
 * @date 2020-8-6
 * @说明 数据统计
 **/
@RestController
@RequestMapping("/data/")
public class DataStatisticsController extends BaseController{
    
	@Autowired
    private DataStatisticsService dataStatisticsService;

    /**
     * @return 综合统计(灾害点、项目、安装布置点、设备、传感器)
     **/
    @PostMapping(value="countBaseNum")
    public Result countBaseNum() {
        Result result = new Result();
        TabUserVo userVo = getCurrentUser();
        userVo.setAreaCode(userVo.getAreaCode());
        userVo.setLevel(userVo.getLevel());
        userVo.setId(userVo.getId());
        Map<String,Object> map = dataStatisticsService.countBaseNum(userVo);
        result.setData(map);
        return result;
    }
    /**
     * @return 害点类型统计
     **/
    @PostMapping(value="countBasicTypeNum")
    public Result countBasicTypeNum() {
        Result result = new Result();
        TabUserVo userVo = getCurrentUser();
        userVo.setAreaCode(userVo.getAreaCode());
        userVo.setLevel(userVo.getLevel());
        userVo.setId(userVo.getId());
        List<Map<String,Object>> list=dataStatisticsService.countBasicTypeNum(userVo);
        result.setData(list);
        return result;
    }
    /**
     * @return 设备累计告警统计
     **/
    @PostMapping(value="countDeviceAlarmNum")
    public Result countDeviceAlarmNum() {
        Result result = new Result();
        List<Map<String,Object>> list = 
        		dataStatisticsService.countDeviceAlarmNum(getCurrentUser().getId());
        result.setData(list);
        return result;
    }
    /**
     * @return 设备在线离线统计
     **/
    @PostMapping(value="countDeviceStateNum")
    public Result countDeviceStateNum() {
        Result result = new Result();
        List<Map<String,Object>> list =
        		dataStatisticsService.countDeviceStateNum(getCurrentUser().getId());
        result.setData(list);
        return result;
    }
    /**
     * @return 设备在离线情况
     **/
    @GetMapping(value="deviceStateSituation")
    public Result deviceStateSituation(Pageable pageable) {
    	Result result = new Result();
    	List<Map<String,Object>> list = 
    		dataStatisticsService.deviceStateSituation(getCurrentUser().getId());
    	result.setData(list);
    	result.setCount(list.size());
    	return result;
    }
    
    /**
     * @return 状态统计（1日无数据、2日无数据、3日无数据、4日及以上无数据、正常）
     **/
    @PostMapping(value="countInstrumentNum")
    public Result countInstrumentNum() {
        Result result = new Result();
        Integer uId = getCurrentUser().getId();
        Map<String,Object> map = dataStatisticsService.countInstrumentNum(uId);
        result.setData(map);
        return result;
    }
    /**
     * @return 监测方法（设备类型）统计
     **/
    @PostMapping(value="countMonitorTypeNum")
    public Result countMonitorTypeNum() {
        Result result = new Result();
        Integer uId = getCurrentUser().getId();
        List<Map<String,Object>> list=dataStatisticsService.countMonitorTypeNum(uId);
        result.setData(list);
        return result;
    }

    /**
     * @param pageable
     * @return 分页参数
     **/
    @PostMapping(value="countDeviceStateNum1")
    public Result countDeviceStateNum1(Pageable pageable) {
    	Result result = new Result();
    	result.setData(null);
        return result;
    }
    
}